<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

//Route::middleware('auth:api')->get('/user', function (Request $request) {
//    return $request->user();
//});
Route::group(['namespace' => 'API'], function () {

    /**
     * 员工管理
     */
    Route::resource('users', 'BackgroundUserController',['middleware'=>'auth:api']);
    Route::resource('roles', 'RoleController',['middleware'=>'auth:api']);
    Route::get('/roles-list','RoleController@lists');
    Route::resource('permissions','PermissionController');
    Route::resource('logs', 'AdminLogController');
    Route::resource('teachers','TeacherController');
    Route::resource('student-logs','StudentLogController');
    Route::get('/professional/export','ProfessionalController@export');
    Route::resource('professional','ProfessionalController');
    Route::get('/professional-user','ProfessionalController@professionalUser');
    Route::post('/professional-import','ProfessionalController@import');
    Route::get('/user-infos/{token}', 'BackgroundUserController@getUserByToken');
    Route::get('/user-roles/{token}', 'BackgroundUserController@getUserPermissions');
    Route::get('/organizational','OrgController@order');
    Route::get('/org-list','OrgController@select');
    Route::get('/binding', 'LoginController@index');
    Route::get('student-search','StudentController@studentSearch');
//    /**
//     * 科室管理
//     */
//    Route::resource('companys', 'CompanyController');
//    Route::get('/companys-list', 'CompanyController@getList');
//    /**
//     * 职务管理
//     */
//    Route::resource('posts', 'PostController');
//    Route::get('/posts-list', 'PostController@getList');

    /**
     * 学生列表
     */
    Route::resource('students', 'StudentController',['middleware'=>'auth:api']);
    Route::post('/student-relation','StudentController@relation');
    Route::post('/student-info','StudentController@info');
    Route::post('/student-relieve','StudentController@relieve');
    Route::post('/login','BackgroundUserController@loginService');

    /**
     * 班级列表
     */
    Route::resource('classes', 'ClassController');
    /**
     * 学年列表
     */
    Route::resource('semesters', 'SemesterController',['middleware'=>'auth:api']);
    Route::get('semesters-list','SemesterController@getList');
    Route::get('see-semesters','SemesterController@getSemesterList');
    Route::post('student-calendar','CalendarController@index');
    Route::get('/user-exam/{id}','UserExamController@index');
    Route::get('/user-course/{id}','UserExamController@course');
    Route::get('/get-exam/{id}','UserExamController@exams');
    Route::get('/get-english/{id}','UserExamController@englishs');
    Route::post('/wx-exam','UserExamController@wxIndex');
    Route::post('/wx-course','UserExamController@wxCourse');
    Route::post('/wx-code','UserExamController@code');
    Route::post('/check-user','ProfessionalController@check');
    Route::post('/upload-authentication','ProfessionalController@upload');

    Route::post('/student-english','StudentEnglishController@index');


    Route::apiResource('/backend-student-info','StudentsInfoController');
    Route::get('/export-info-all','StudentsInfoController@exportAll');
    Route::get('/export-info-correct','StudentsInfoController@exportCorrect');
    Route::post('/get-user-info-by-openid','StudentsInfoController@getStudentInfoByOpenid');
    Route::get('/confirm-user-info/{id}','StudentsInfoController@confirmUserInfo');
    Route::post('/correct-user-info','StudentsInfoController@correctUserInfo');
    /**
     * 课程
     */
    Route::group(['prefix' => 'course', 'namespace' => 'Course'], function () {

        /**
         * 课程相关
         */
        Route::resource('/course', 'CourseController',['middleware'=>'auth:api']);
        Route::any('/course-import','CourseController@import',['middleware'=>'auth:api']);
        Route::any('/select-import','CourseController@select',['middleware'=>'auth:api']);
        Route::post('/schedule','CourseController@schedule');
    });
    Route::group(['prefix' => 'classGroup', 'namespace' => 'ClassGroup','middleware'=>'auth:api'], function () {

        /**
         * 课程相关
         */
        Route::resource('/classGroup', 'ClassGroupController');
        Route::post('/get-list', 'ClassGroupController@getList');
        Route::resource('/studentGroup','StudentGroupController');
        Route::resource('/students','ElectiveStudentController');
        Route::post('/join-group','StudentGroupController@join');
        Route::post('/check','StudentGroupController@check');
        Route::post('/student-join','StudentGroupController@getUsersLog');
        Route::get('/field','ElectiveStudentController@field');
        Route::get('/selection','ClassGroupController@selection');
        Route::get('/export','ClassGroupController@export');
    });
    Route::group(['prefix' => 'WeChat', 'namespace' => 'WeChat'], function () {

        /**
         * 课程相关
         */
        Route::resource('/list', 'WeChatController');
        Route::get('/type', 'WeChatController@type');
        Route::get('/name-list', 'WeChatController@getList');
        Route::get('/get-default', 'WeChatController@getDefault');
        Route::post('/messageReply', 'WeChatMessageController@messageReply');
        Route::resource('/WeChatMessage','WeChatMessageController');
        Route::resource('/WeChatUser','WeChatUsersController');
        Route::resource('/WeChatImg','WeChatImgSourceController');
        Route::resource('/WeChatArt','WeChatArtSourceController');
        Route::resource('/WeChatVoice','WeChatVoiceController');
        Route::resource('/WeChatVideo','WeChatVideoController');
        Route::resource('/WeChatReply','ReplyRuleController');
        Route::resource('/WeChatTemplate','TemplateMessageController');
        Route::resource('/MassLog','MassLogController');
        Route::resource('/MyMassLog','MyMassLogController');
        Route::get('/WeChatSource','WeChatArtSourceController@WeChatSource');
    });
    /**
     * 考试
     */
    Route::group(['prefix' => 'exam', 'namespace' => 'Exam','middleware'=>'auth:api'], function () {

        /**
         * 课程相关
         */
        Route::resource('/exam-list', 'ExamController');
        Route::resource('/exam-result', 'ExamResultController');
        Route::any('/exam-import','ExamController@import');
        Route::any('/student-import','ExamController@importStudent');
        Route::any('/code-import','ExamResultController@select');

    });
    Route::group(['prefix' => 'english', 'namespace' => 'English','middleware'=>'auth:api'], function () {

        /**
         * 课程相关
         */
        Route::resource('/english-list', 'EnglishController');
        Route::any('/english-import','EnglishController@import');
    });

//    Route::group(['prefix' => 'statistic'], function () {
//        Route::get('/payout-pie', 'StatisticController@getPayoutDataForPieEcharts');
//    });

    /**
     * 系统参数
     */
//    Route::get('/properties', 'PropertyController@index');
});
